package org.laperra.tienda.model;

import java.io.Serializable;

import java.lang.StringBuilder;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllUsuarios", query = "select myUsuario from Usuario myUsuario"),
		@NamedQuery(name = "findUsuarioByEmail", query = "select myUsuario from Usuario myUsuario where myUsuario.email = ?1"),
		@NamedQuery(name = "findUsuarioByEmailContaining", query = "select myUsuario from Usuario myUsuario where myUsuario.email like ?1"),
		@NamedQuery(name = "findUsuarioByName", query = "select myUsuario from Usuario myUsuario where myUsuario.name = ?1"),
		@NamedQuery(name = "findUsuarioByNameContaining", query = "select myUsuario from Usuario myUsuario where myUsuario.name like ?1"),
		@NamedQuery(name = "findUsuarioByPrimaryKey", query = "select myUsuario from Usuario myUsuario where myUsuario.userName = ?1"),
		@NamedQuery(name = "findUsuarioByTelefono", query = "select myUsuario from Usuario myUsuario where myUsuario.telefono = ?1"),
		@NamedQuery(name = "findUsuarioByTelefonoContaining", query = "select myUsuario from Usuario myUsuario where myUsuario.telefono like ?1"),
		@NamedQuery(name = "findUsuarioByUserName", query = "select myUsuario from Usuario myUsuario where myUsuario.userName = ?1"),
		@NamedQuery(name = "findUsuarioByUserNameContaining", query = "select myUsuario from Usuario myUsuario where myUsuario.userName like ?1") })
@Table(catalog = "laperra", name = "usuario")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "perra/org/laperra/tienda/domain", name = "Usuario")
public class Usuario implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "userName", length = 25, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	String userName;
	/**
	 */

	@Column(name = "name", length = 25, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String name;
	/**
	 */

	@Column(name = "email", length = 45, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String email;
	/**
	 */

	@Column(name = "telefono", length = 9, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String telefono;

	/**
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 */
	public String getUserName() {
		return this.userName;
	}

	/**
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 */
	public String getName() {
		return this.name;
	}

	/**
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 */
	public String getEmail() {
		return this.email;
	}

	/**
	 */
	public void setTelefono(String telefono) {
		this.telefono = telefono;
	}

	/**
	 */
	public String getTelefono() {
		return this.telefono;
	}

	/**
	 */
	public Usuario() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Usuario that) {
		setUserName(that.getUserName());
		setName(that.getName());
		setEmail(that.getEmail());
		setTelefono(that.getTelefono());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("userName=[").append(userName).append("] ");
		buffer.append("name=[").append(name).append("] ");
		buffer.append("email=[").append(email).append("] ");
		buffer.append("telefono=[").append(telefono).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((userName == null) ? 0 : userName.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Usuario))
			return false;
		Usuario equalCheck = (Usuario) obj;
		if ((userName == null && equalCheck.userName != null) || (userName != null && equalCheck.userName == null))
			return false;
		if (userName != null && !userName.equals(equalCheck.userName))
			return false;
		return true;
	}
}
